/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc.ex;

import cn.yzc.pojo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>Project: SpringMVCPro - GlobalException</p>
 * <p>Powered by yzc On 2023-11-01 09:31:34</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */

/**
 * 全局异常
 */
@ControllerAdvice //专门用于控制类的异常增强
@ResponseBody
public class GlobalException {

    @ExceptionHandler(Exception.class)
    public Result ex(Exception e){
        return new Result(404,"页面丢了",e.toString());
    }


    @ExceptionHandler(ValidateException.class)
    public Result validator(ValidateException e){return new Result(0,"验证错误",e.getErrors());}
}
